package com.gxa.service.Impl;

import com.gxa.common.R;
import com.gxa.mapper.zhy.SystemSettingsMapper;
import com.gxa.pojo.System_Config_Param;
import com.gxa.service.SystemSettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * User: 赵贺益
 * Date: 2021/12/05 13:22
 * Description:
 * Version: V1.0
 */
@Service
public class SystemSettingsServiceImpl implements SystemSettingsService {
    @Autowired
    private SystemSettingsMapper systemSettingsMapper;
    /**
     * 查询系统设置信息
     * @return
     * @param absoultePath
     */
    @Override
    public R querySystemConfig(String absoultePath) {
        R r=new R();
        System_Config_Param system_config_param=systemSettingsMapper.querySystemConfig();
        //当前logo图片文件的绝对路径
//        String truthPath=absoultePath+system_config_param.getLogo();
//        system_config_param.setLogo(truthPath);
        if(system_config_param!=null){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(system_config_param);
        }else {
            r.setCode(500);
            r.setMsg("系统出错，请联系管理员");
        }
        return r;
    }



    /**
     * 修改系统设置信息
     * @param system_config_param
     * @return
     */
    @Override
    public R updateSystemConfig(System_Config_Param system_config_param) {
        R r=new R();
        int result=systemSettingsMapper.updateSystemConfig(system_config_param);
        if(result>0){
            r.setCode(200);
            r.setMsg("修改成功");
        }else {
            r.setCode(500);
            r.setMsg("后台服务错误");
        }
        return r;
    }
}
